package db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class DBManager {

	private String url = "";
	private String driverName = "";
	private String userID;
	private String userPW;	
	private static DBManager dbManager = new DBManager();	
		
	private DBManager(){
	}
	
	public static DBManager getInstance(){
		return dbManager;
	}
	
	public Connection getConnection(){
		Connection connection = null;
	
		try{
			Class.forName(driverName).newInstance();
			connection = DriverManager.getConnection(url,userID,userPW);
		}catch(Exception e){
			e.printStackTrace();
		}

		return connection;
	}
	
	public void closeConnection(Connection connection) throws SQLException{
		try {
			connection.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			connection.close();
		}
	}
	

}
